﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using System.Text;
using MyMario.Helpers;
using Microsoft.Xna.Framework.Graphics;


namespace MyMario.GameObject
{
    class Person: GameObject
    {

        Texture2D runleft;
        Texture2D runright;
        Texture2D jump;
        bool isRunning;
        bool isRunningRight;
        bool isJumping;
        float yVelocity;
        float maxYVelocity = 10;
        


            public Person(Rectangle rect, float scale, Texture2D runright, Texture2D runleft, Texture2D jump )
            : base(rect, LoadHelp.Textures[TextureEnum.Person])
            {
                this.runright = runright;
                this.runleft = runleft;
                this.jump = jump;
            }

            public float YVelocity
            {
                get { return yVelocity; }
                set { yVelocity = value; }
            }

            public bool IsJumping
            {
                get { return isJumping; }
                set { isJumping = value; }
            }

            

            public void StartRun(bool isRight)
            {
                isRunning = true;
                isRunningRight = isRight;
            }
            public void Stop()
            {
                isRunning = false;
               
            }
            
            

          /*  public Rectangle NextPosition(int dx)
            {
                
            }*/

            public void Jump()
            {
                if (!isJumping && yVelocity <= 0.0f)
                {
                    isJumping = true;
                    yVelocity = maxYVelocity;
                }
            }

            /*public void Move(int dx, int dy)
            {
                if (position.X + dx > 0 && position.X + dx + width < MarioGame.Width)
                    position.X += dx;

                if (position.Y + dy > 0 && position.Y + dy + height < MarioGame.Height)
                    position.Y += dy;
            }*/

            /*public void Place(int x, int y)
            {
                position.X = x;
                position.Y = y;
            }*/

            public override void Draw(SpriteBatch spritebatch)
            {
                
                if (isRunning)
                {
                    if (isRunningRight)
                        spritebatch.Draw(runright, rect, Color.White);
                    else
                        spritebatch.Draw(runleft, rect, Color.White);
                }
                else
                    if (isJumping)
                        spritebatch.Draw(jump, rect, Color.White);
                    else
                    {
                        spritebatch.Draw(this.Texture, rect, Color.White);
                    }
                
            }
        }
    }

